package cn.com.yto56.cainiao.exponent.common;

import java.util.LinkedHashMap;
import java.util.Map;

public class ExponentTypeMapper {
    private static final Map<String, String> EXPONENT_TYPE_MAPPER_CACHE = new LinkedHashMap<>();

    static {
        EXPONENT_TYPE_MAPPER_CACHE.put("线路时效达成率", "t1");

        EXPONENT_TYPE_MAPPER_CACHE.put("及时揽收率", "t2");
        EXPONENT_TYPE_MAPPER_CACHE.put("超18小时", "t2d1");

        EXPONENT_TYPE_MAPPER_CACHE.put("信息完整率", "t3");
        EXPONENT_TYPE_MAPPER_CACHE.put("国际件", "t3d1");
        EXPONENT_TYPE_MAPPER_CACHE.put("时效件", "t3d2");
        EXPONENT_TYPE_MAPPER_CACHE.put("揽收节点缺失", "t3d3");
        EXPONENT_TYPE_MAPPER_CACHE.put("中心节点缺失", "t3d4");
        EXPONENT_TYPE_MAPPER_CACHE.put("派送节点缺失", "t3d5");
        EXPONENT_TYPE_MAPPER_CACHE.put("签收节点缺失", "t3d6");

        EXPONENT_TYPE_MAPPER_CACHE.put("信息准确率", "t4");
        EXPONENT_TYPE_MAPPER_CACHE.put("揽收信息不准确", "t4d1");
        EXPONENT_TYPE_MAPPER_CACHE.put("签收信息不准确", "t4d2");
        EXPONENT_TYPE_MAPPER_CACHE.put("派送信息不准确", "t4d3");
        EXPONENT_TYPE_MAPPER_CACHE.put("中心信息不准确", "t4d4");
        EXPONENT_TYPE_MAPPER_CACHE.put("代收点信息不准确", "t4d5");
        EXPONENT_TYPE_MAPPER_CACHE.put("妈妈驿站", "t4d6");
        EXPONENT_TYPE_MAPPER_CACHE.put("代办点-丰巢", "t4d7");
        EXPONENT_TYPE_MAPPER_CACHE.put("代办点-第三方", "t4d8");
    }

    public static Map<String, String> getExponentTypeMapper() {
        return new LinkedHashMap<>(EXPONENT_TYPE_MAPPER_CACHE);
    }

    public static String get(String k) {
        return EXPONENT_TYPE_MAPPER_CACHE.getOrDefault(k, k);
    }

    public static String convert(final String data) {
        String cache = data;
        for (Map.Entry<String, String> e : EXPONENT_TYPE_MAPPER_CACHE.entrySet()) {
            cache = cache.replace(e.getKey(), e.getValue());
        }
        return cache;
    }
}
